package com.buss.product.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonWriteNullProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.buss.core.dic.RecordStatus;

@Entity
@Table(name="base_catepropgroup")
@TableGenerator(name="catepropgroup_pk_sequence",initialValue=1,allocationSize=1,pkColumnName="seq_col",
		pkColumnValue="catepropgroup_seq",valueColumnName="seq_val",table="product_pk_sequence")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonIgnoreProperties(value={"categorys"})
public class CatePropGroup implements Serializable {

	private static final long serialVersionUID = -4181089045032207461L;

	/**分组ID*/
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="catepropgroup_pk_sequence")
	private Long id;
	
	/**单位编码*/
	@Column(nullable=false,length=50)
	private String companyId;
	
	/**分组名称*/
	@Column(nullable=false,length=100)
	private String name;
	
	/**显示名称*/
	@Column(nullable=false,length=100)
	private String displayName;
	
	/**分组描述*/
	@Column(length=500)
	private String intro;
	
	/**排序序号*/
	private Long sortOrder;
	
	/**状态：normal:正常，deleted：已删除，disabled：不可用。默认为：normal*/
	@Enumerated(value=EnumType.STRING)
	private RecordStatus status;

	/**
	 * 属性分组对应商品分类信息列表
	 */
	@ManyToMany(cascade=CascadeType.REFRESH,fetch=FetchType.LAZY,mappedBy="propGroups")
	private List<GoodsCategory> categorys;
	
	@Transient
	private List<CateProp> props;
	
	/**是否允许删除*/
	@Transient
	private Long categoryId;
	
	public CatePropGroup(){}
	
	public CatePropGroup(Long id,String companyId,String name,String displayName,String intro,Long sortOrder,
			RecordStatus status,Long categoryId){
		this.id = id;
		this.companyId = companyId;
		this.name = name;
		this.displayName = displayName;
		this.intro = intro;
		this.sortOrder = sortOrder;
		this.status = status;
		this.categoryId = categoryId;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public Long getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Long sortOrder) {
		this.sortOrder = sortOrder;
	}

	public RecordStatus getStatus() {
		return status;
	}

	public void setStatus(RecordStatus status) {
		this.status = status;
	}

	public List<GoodsCategory> getCategorys() {
		return categorys;
	}

	public void setCategorys(List<GoodsCategory> categorys) {
		this.categorys = categorys;
	}

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	public List<CateProp> getProps() {
		return props;
	}

	public void setProps(List<CateProp> props) {
		this.props = props;
	}

	
}
